﻿@model PopForums.Models.PagedTopicContainer
@using PopForums.Controllers
@using PopForums.Extensions;

@{
    ViewBag.Title = PopForums.Resources.Search;
    Layout = "~/Areas/PopForums/Views/Shared/PopForumsMaster.cshtml";
}

@section HeaderContent {
	<script type="text/javascript" language="javascript">
		$(function () {
			PopForums.topicPreviewSetup();
			PopForums.startTimeUpdater();
		});
	</script>
}

<div id="TopBreadcrumb" class="navAbsolute">
	<h1>@PopForums.Resources.Search</h1>
	<p>
		@Html.ActionLink(PopForums.Resources.Recent, "Recent", ForumController.Name, new { page = 1 }, null)
		^ @Html.ActionLink(PopForums.Resources.Forums, "Index", ForumHomeController.Name, null, null)
	</p>
</div>

<div id="SearchForm">
@using (Html.BeginForm("Process", "Search"))
{
	<p>
		@Html.TextBox("Query")
		@Html.DropDownList("SearchType", (SelectList)ViewBag.SearchTypes)
		<input type="submit" value="@PopForums.Resources.Search" />
	</p>
}
</div>

@Html.PagerLinks("Search", "Result", Model.PagerContext, "pagerLinks", "morePager", "currentPager")

@if (Model.Topics.Count == 0 && !String.IsNullOrEmpty(ViewBag.Query))
{
	<p>@PopForums.Resources.NoResults</p>
}
else
{
	<table class="forumGrid">
		@foreach (var topic in Model.Topics)
		{
			<tr @if (topic.IsDeleted) {<text> class="deletedItem"</text> }>
				<td class="newIndicator">
					@if (this.GetUserFromViewData() == null)
					{
						<a href="@Url.Action("Topic", "Forum", new { id = topic.UrlName, page = 1 })">@Html.TopicReadIndicator(topic, Model, "/Content/PopForums/")</a>
					}
					else
					{
						<a href="@Url.Action("GoToNewestPost", "Forum", new { id = topic.TopicID })">@Html.TopicReadIndicator(topic, Model, "/Content/PopForums/")</a>
					}
				</td>
				<td>
					<h2>@Html.ActionLink(topic.Title, "Topic", "Forum", new { id = topic.UrlName, page = 1 }, null) <span class="topicPreviewButton" title="@PopForums.Resources.PreviewTopic" topicID="@topic.TopicID">&gt;&gt;</span></h2>
					<div id="TopicPreview@(topic.TopicID)" class="topicPreview"></div>
					<p class="forumStatData">
						@PopForums.Resources.StartedBy: @topic.StartedByName @PopForums.Resources.In @Model.ForumTitles[topic.ForumID] | @PopForums.Resources.Views: @topic.ViewCount | @PopForums.Resources.Replies: @topic.ReplyCount | @PopForums.Resources.Last: <span class="lastPostTime fTime" data-utc="@FormatTime8601(topic.LastPostTime)">@FormatTime(topic.LastPostTime)</span> @PopForums.Resources.By @topic.LastPostName
					</p>
				</td>
			</tr>
		}
	</table>
}